/*
 * @Author: ZhanXie
 * @Date: 2020-09-01 16:44:15
 * @LastEditors: ZhanXie
 * @LastEditTime: 2020-09-01 17:01:35
 * @Description: 加密方法
 * @FilePath: /weibo/src/utils/cryp.js
 */

const crypto = require('crypto')
const { CRYPTO_SECRET_KEY } = require('../conf/secretKeys')

/**
 * md5 加密
 * @param {string} content 明文 
 */
function _md5(content) {
  const md5 = crypto.createHash('md5')
  return md5.update(content).digest('hex')
}

/**
 * 加密方法
 * @param {string} content 铭文
 */
function doCrypto(content) {
  const str = `password=${content}&key=${CRYPTO_SECRET_KEY}`
  return _md5(str)
}

module.exports = {
  doCrypto
}